package com.hourupdate.network.bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.hourupdate.network.connection.ConnectionJDBC;

public class SendMassageTime {
	static final Logger logger = Logger.getLogger(SendMassageTime.class);
	private String send_massage_id = null;
	private String send_massage_time = null;
	public String getSend_massage_id() {
		return send_massage_id;
	}
	public void setSend_massage_id(String send_massage_id) {
		this.send_massage_id = send_massage_id;
	}
	public String getSend_massage_time() {
		return send_massage_time;
	}
	public void setSend_massage_time(String send_massage_time) {
		this.send_massage_time = send_massage_time;
	}
	public boolean insertPreparedStatement(Connection conn){
		String sql = "INSERT INTO "+ConnectionJDBC.schema+"."+ConnectionJDBC.schemaSEND_MASSAGE_TIME+
				" (SEND_MASSAGE_ID, "+
				" SEND_MASSAGE_TIME) "+
				" VALUES"+
				" ("+
				" ?, "+
				" ?, "+
				" )";
		boolean success = false;
		try {
			PreparedStatement ps = conn.prepareStatement(sql);
			ExecuteSQLBean eb = new ExecuteSQLBean();
			ps.setString(1, this.getSend_massage_id());
			ps.setString(2, this.getSend_massage_time());
			success = eb.executeStatement(ps);
		} catch (SQLException e) {
			logger.error(e.getMessage());
		}
		return success;
	}
	
	public boolean updatePreparedStatement(Connection conn){
		String sql = "UPDATE "+ConnectionJDBC.schema+"."+ConnectionJDBC.schemaSEND_MASSAGE_TIME+
				" SET "+
				" SEND_MASSAGE_TIME = ? "+
				" WHERE "+
				" SEND_MASSAGE_ID = ? ";
		boolean success = false;
		try {
			PreparedStatement ps = conn.prepareStatement(sql);
			ExecuteSQLBean eb = new ExecuteSQLBean();
			ps.setString(1, this.getSend_massage_time());
			ps.setString(2, this.getSend_massage_id());
			success = eb.executeStatement(ps);
		} catch (SQLException e) {
			logger.error(e.getMessage());
		}
		return success;
	}
}
